package com.gzhryc.jdbc.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class ModelJDKProxy extends ModelProxy implements InvocationHandler{
	
	public ModelJDKProxy(Object obj){
		super(obj);
	}
	
	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		before(method,args);
		return method.invoke(this.obj,args);
	}

	@SuppressWarnings("unchecked")
	public<T> T wrap() {
		return (T)Proxy.newProxyInstance(this.getObjectClass().getClassLoader(),this.getObjectClass().getInterfaces(),this);
	}
}
